const { InfluxDB } = require('@influxdata/influxdb-client')
const { DB_CONFIG } = require('../config/db')

const client = new InfluxDB({ url: DB_CONFIG.url, token: DB_CONFIG.token })

const queryApi = client.getQueryApi(DB_CONFIG.org)

const execQuery = (query) => {
  return queryApi.collectRows(query)
}

module.exports = {
  execQuery,
}
